package Week2;

import java.util.*;

public class Day12 {
}

//牛客:OR63 删除公共字符
class Main12 {
    //模拟哈希表
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String s2 = in.nextLine();
        //将第二个字符串的所有字符放入哈希表中
        int[] arr = new int[256];
        for(int i = 0; i < s2.length(); i++){
            arr[s2.charAt(i)]++;
        }

        //遍历第一个字符串
        for(int i = 0; i < s1.length(); i++){
            //如果此时的字符在哈希表中存在就不打印
            if(arr[s1.charAt(i)] == 0){
                System.out.print(s1.charAt(i));
            }
        }
    }
}

//牛客:JZ52 两个链表的第一个公共结点
class Solution6 {
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        ListNode cur1 = pHead1;
        ListNode cur2 = pHead2;
        int cnt1 = 0, cnt2 = 0, cnt3 = 0;
        //计算两个链表的长度
        while(cur1 != null){
            cnt1++;
            cur1 = cur1.next;
        }
        while(cur2 != null){
            cnt2++;
            cur2 = cur2.next;
        }
        //求出长度的差值
        //但要判断是哪个链表长
        if(cnt1 > cnt2){
            cnt3 = cnt1 - cnt2;
        }else{
            cnt3 = cnt2 - cnt1;
            //将长的链表用pHead1指向
            ListNode tmp = pHead1;
            pHead1 = pHead2;
            pHead2 = tmp;
        }

        //移动长的链表使两个链表此时引用指向节点到最后节点的长度相同
        while(cnt3-- != 0){
            pHead1 = pHead1.next;
        }

        //同时移动两个引用
        while(pHead1 != null && pHead2 != null){
            //如果两个引用指向节点的值是相同的就放回此时位置到最后的链表
            if(pHead1.val == pHead2.val){
                return pHead1;
            }
            pHead1 = pHead1.next;
            pHead2 = pHead2.next;
        }
        //没有找到相同的节点返回null
        return null;
    }
}


//牛客:mari和shiny
class Main13 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String str = in.next();
        long s = 0 , h = 0 , y = 0;
        for(int i = 0; i < n; i++){
            //记录字符s的个数
            if(str.charAt(i) == 's') s++;
            //一个字符h对应全部的字符s,所以s和h的组合为，h个s
            else if(str.charAt(i) == 'h') h += s;
            //一个字符y对应全部的字符sh,所以sh和y的组合为，y个sh
            else if(str.charAt(i) == 'y') y += h;
        }
        //最后y的数量就是shy的所以组合个数
        System.out.println(y);
    }
}
